<template>
  <div class="app-container" >
    <div class="filter-container">
      <el-date-picker v-model="listQuery.record_date_start" style="width:140px;" format="yyyy-MM-dd" type="datetime" placeholder="跟进日期" />
      <!-- <el-date-picker v-model="listQuery.record_date_end" style="width:140px;" format="yyyy-MM-dd" type="datetime" placeholder="跟进日期" /> -->
      <el-date-picker v-model="listQuery.pass_time" style="width:120px;" format="yyyy-MM" type="month" placeholder="签署日期" />
      <el-input v-model="listQuery.real_name" placeholder="客户姓名" style="width: 110px;;margin-top:8px;" class="filter-item"
        @keyup.enter.native="handleFilter" />
        <el-select v-model="listQuery.investor_id" placeholder="选择资方" filterable class="filter-item" style="width:110px;margin-top:6px">
        <el-option label="选择资方" value="" />
        <el-option
          v-for="item in investor"
          :key="item.id"
          :label="item.name"
          :value="item.id"
        />
      </el-select>
      <el-select v-model="listQuery.overdue" placeholder="逾期期数" class="filter-item" style="width: 110px;margin-top:8px;">
        <el-option label="所有" value="10" />
        <el-option label="M0" value="20" />
        <el-option label="M1" value="1" />
        <el-option label="M2" value="2" />
        <el-option label="M3" value="3" />
        <el-option label="M3+" value="4" />
      </el-select>
      <el-input v-model="listQuery.days" placeholder="逾期天数" type="number" style="width: 110px;;margin-top:8px;" class="filter-item"
        @keyup.enter.native="handleFilter" />
      <el-select v-model="listQuery.city" placeholder="选择城市" filterable class="filter-item" style="width:110px;margin-top:8px;" @change="getRegionList">
        <el-option label="选择城市"  value="" />
        <el-option
          v-for="item in city"
          :key="item.city"
          :label="item.name"
          :value="item.city"
        />
      </el-select>
      <el-select v-model="listQuery.merchant" placeholder="选择商户" filterable class="filter-item" style="width:110px;margin-top:6px">
        <el-option label="选择商户" value="" />
        <el-option
          v-for="item in merchant_list"
          :key="item.merchant_id"
          :label="item.merchant_name"
          :value="item.merchant_id"
        />
      </el-select>
      
      <!-- <el-select v-model="listQuery.sale_id" placeholder="选择销售" filterable class="filter-item" style="width:110px;margin-top:6px">
        <el-option label="选择销售" value="" />
        <el-option
          v-for="item in sale_list"
          :key="item.sale_id"
          :label="item.real_name"
          :value="item.sale_id"
        />
      </el-select>
      <el-select v-model="listQuery.b_model" placeholder="放款模式" class="filter-item" style="width:110px;margin-top:6px">
        <el-option label="放款模式" value="" />
        <el-option label="正常" value="1" />
        <el-option label="买断" value="2" />
        <el-option label="绿通" value="3" />
      </el-select> -->

      <!-- <el-select v-model="listQuery.collector_id" placeholder="催收员" filterable class="filter-item" style="width:100px;margin-top:6px">
        <el-option label="催收员" value="" />
        <el-option
          v-for="item in collector"
          :key="item.id"
          :label="item.name"
          :value="item.id"
        />
      </el-select> -->
      <el-select v-model="listQuery.result" placeholder="催收结果" filterable class="filter-item" style="width:110px;margin-top:6px">
        <el-option label="催收结果" value="" />
        <el-option
          v-for="item in way_list.result"
          :key="item.id"
          :label="item.name"
          :value="item.id"
        />
      </el-select>
      <prosecution_place ref="prosecution_place"/>
      <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter" style="margin-top:8px;">
        查询
      </el-button>
      <excelout></excelout>
      <!-- <el-badge :value="notice" class="item" type="warning" style="margin-top:-3px;margin-left:10px" v-if="notice!=0" >
        <el-button @click="getNotice()">系统提醒</el-button>
      </el-badge> -->
      
    </div>

    <el-table  :key="tableKey" v-loading="listLoading" :data="list" :row-class-name="tableRowClassName1" size="mini" border fit highlight-current-row style="width: 100%;"  >
      <!-- <el-table-column type="selection" width="45" align="center" ></el-table-column> -->
      <el-table-column label="操作" align="center" width="115" class-name="small-padding fixed-width" >
        <template slot-scope="{row,$index}" v-if="row.is_paid!=1">
          <el-dropdown :hide-on-click="false" >
            <span class="el-dropdown-link" style="color:#67C23A">
              更多操作
              <i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>
                <el-button size="mini" type="primary" @click="tipsByAdmin(row.order_id,1)">提醒还款</el-button>
              </el-dropdown-item>
              <el-dropdown-item>
                <el-button size="mini" type="danger" @click="record(row.order_id)">催收记录</el-button>
              </el-dropdown-item>
              <el-dropdown-item>
                <el-button size="mini" type="success" @click="plan(row.order_id)">还款计划</el-button>
              </el-dropdown-item>
              <el-dropdown-item v-if="row.investor_id==2">
                <el-button size="mini" type="primary" @click="showHaierMoney(row.order_id)">海尔云贷</el-button>
              </el-dropdown-item>
              <el-dropdown-item>
                <el-button size="mini" type="info" @click="detail(row.order_id)">订单详情</el-button>
              </el-dropdown-item>
              <el-dropdown-item>
                <el-button size="mini" type="danger" @click="prosecutionPlace(row.order_id)">起诉地点</el-button>
              </el-dropdown-item>
              <el-dropdown-item>
                <el-button size="mini" type="success" @click="planinvestor(row)">资方还款</el-button>
              </el-dropdown-item>

            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column>
      <el-table-column label="跟进记录" class-name="status-col" width="85">
        <template slot-scope="{row}">
            <span slot="reference" v-if="row.collect_record!=''"  style="color:#409EFF;cursor:pointer"  @click="record(row.order_id)">{{ row.collect_record[0].collect_time}}</span>
        </template>
      </el-table-column>
      <el-table-column label="签单日期" align="center" width="85" >
        <template slot-scope="{row}">
          <span>{{ row.pass_time }}</span>
        </template>
      </el-table-column>
      <el-table-column label="客户姓名" align="center" width="75" >
        <template slot-scope="{row}">
          <span >{{ row.real_name }}</span>
        </template>
      </el-table-column>
      <el-table-column label="资方" align="center" width="80" >
        <template slot-scope="{row}">
          <span >{{ row.investor_name }}</span>
        </template>
      </el-table-column>
      <el-table-column label="诉讼地" align="center" width="100" >
        <template slot-scope="{row}">
          <span >{{ row.place }}</span>
        </template>
      </el-table-column>
      <el-table-column label="公众号" align="center" width="65">
        <template slot-scope="{row}">
          <span v-if="row.openid!=''">已关注</span>
          <span v-if="row.openid==''" style="color:#aaa">未关注</span>
        </template>
      </el-table-column>
      <el-table-column label="手机号码" align="center" width="95">
        <template slot-scope="{row}">
          <span>{{ row.mobile }}</span>
        </template>
      </el-table-column>
      <el-table-column label="签单人" class-name="status-col" width="65">
        <template slot-scope="{row}">
          {{ row.sale_name}}
        </template>
      </el-table-column>
      <el-table-column label="催收人" class-name="status-col" width="65">
        <template slot-scope="{row}">
          {{ row.collector_name}}
        </template>
      </el-table-column>
      <el-table-column label="商户名称" align="center" width="70">
        <template slot-scope="{row}">
          <span>{{ row.merchant_name }}</span>
        </template>
      </el-table-column>
      <el-table-column label="模式" align="center" width="60">
        <template slot-scope="{row}">
          <span v-if="row.factoring_model==1">正常</span>
          <span v-if="row.factoring_model==2">买断</span>
          <span v-if="row.factoring_model==3">绿通</span>
        </template>
      </el-table-column>
      <el-table-column label="项目名称" align="center" width="170">
        <template slot-scope="{row}">
          <span>{{ row.project_name }}</span>
        </template>
      </el-table-column>
      <el-table-column label="债权" align="center" width="80">
        <template slot-scope="{row}">
          <span>{{ row.all_total_money }}</span>
        </template>
      </el-table-column>
      <el-table-column label="期数" align="center" width="50">
        <template slot-scope="{row}">
          <span>{{ row.total_period }}</span>
        </template>
      </el-table-column>
      <el-table-column label="已还" align="center" width="70">
        <template slot-scope="{row}">
          <span>{{ row.paid_money }}</span>
        </template>
      </el-table-column>
      
      <el-table-column label="逾期数" align="center" width="60">
        <template slot-scope="{row}">
          <span>{{ row.overdue_count }}</span>
        </template>
      </el-table-column>
      <el-table-column label="逾期金额" align="center" width="80">
        <template slot-scope="{row}">
          <span>{{ row.overdue_total_money }}</span>
        </template>
      </el-table-column>
      <el-table-column label="逾期天数" class-name="status-col" width="70">
        <template slot-scope="{row}">
          {{ row.overdue_days}}
        </template>
      </el-table-column>
      <el-table-column label="滞纳金" class-name="status-col" width="80">
        <template slot-scope="{row}">
          {{ row.late_fee}}
        </template>
      </el-table-column> 
      <el-table-column label="回购金额" class-name="status-col" width="80">
        <template slot-scope="{row}">
          {{ row.buy_back_money}}
        </template>
      </el-table-column> 
      <el-table-column label="回购本金" class-name="status-col" width="80">
        <template slot-scope="{row}">
          {{ row.buy_back_benjin}}
        </template>
      </el-table-column> 
      <el-table-column label="回购时间" class-name="status-col" width="100">
        <template slot-scope="{row}">
          {{ row.buy_back_time}}
        </template>
      </el-table-column> 
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList(listQuery)" />
    <el-dialog :visible.sync="dialogPlanAble" class="abow_dialog" title="还款计划"  width="1050px" >
        <el-table  :key="tableKey" v-loading="listLoading" :data="plan_list" :row-class-name="tableRowClassName" border fit highlight-current-row style="width: 100%;">
          <el-table-column label="客户姓名" align="center" width="180" >
            <template slot-scope="{row}">
              <span>{{ orderinfo.real_name }}</span>
            </template>
          </el-table-column>
          <el-table-column label="期数" align="center" width="60" >
            <template slot-scope="{row}">
              <span>{{ row.num }}</span>
            </template>
          </el-table-column>
          <el-table-column label="应还日期" align="center" width="120" >
            <template slot-scope="{row}">
              <span>{{ row.time_date }}</span>
            </template>
          </el-table-column>
          <el-table-column label="应还金额" align="center" width="120" >
            <template slot-scope="{row}">
              <span>{{ row.total_money }}</span>
            </template>
          </el-table-column>
          <!-- <el-table-column label="利息" align="center" width="110" >
            <template slot-scope="{row}">
              <span>{{ row.money_rate }}</span>
            </template>
          </el-table-column> -->
          <el-table-column label="滞纳金" align="center" width="100" >
            <template slot-scope="{row}">
              <span>{{ row.late_fee }}</span>
            </template>
          </el-table-column>
          <el-table-column label="实还金额" align="center" width="120" >
            <template slot-scope="{row}">
              <span>{{ row.paid_money }}</span>
            </template>
          </el-table-column>
          <el-table-column label="实还日期" align="center" width="180" >
            <template slot-scope="{row}">
              <span v-if="row.paid_date!=0">{{ row.sh_time }}</span>
            </template>
          </el-table-column>
          
          <el-table-column label="还款状态" class-name="status-col" >
            <template slot-scope="{row}">
              {{ row.status_name}}
            </template>
          </el-table-column>
        </el-table>
    </el-dialog>
    <el-dialog :visible.sync="dialogHaierPlanAble" class="abow_dialog" title="海尔云贷"  width="1350px" >
      <el-table :key="tableKey" v-loading="listLoading" :data="haier_plan_list" :row-class-name="tableRowClassNameHaier"  border fit highlight-current-row style="width: 100%;margin-top:20px">
        <el-table-column label="期次" align="center" >
          <template slot-scope="{row}">
            <span>{{ row.term }}</span>
          </template>
        </el-table-column>
        <el-table-column label="应还日期" align="center" >
          <template slot-scope="{row}">
            <span>{{ row.paidDate }}</span>
          </template>
        </el-table-column>
        <el-table-column label="应还本金" align="center" >
          <template slot-scope="{row}">
            <span>{{ row.shouldPrin }}</span>
          </template>
        </el-table-column>
        <el-table-column label="应还利息" align="center" >
          <template slot-scope="{row}">
            <span>{{ row.shouldInter }}</span>
          </template>
        </el-table-column>
        <el-table-column label="应还本金罚息" align="center" >
          <template slot-scope="{row}">
            <span>{{ row.shouldPrinPenalty }}</span>
          </template>
        </el-table-column>
        <el-table-column label="应还利息罚息" align="center" >
          <template slot-scope="{row}">
            <span>{{ row.shouldInterPenalty }}</span>
          </template>
        </el-table-column>
        <el-table-column label="应还总金额" align="center" >
          <template slot-scope="{row}">
            <span>{{ row.samt }}</span>
          </template>
        </el-table-column>
        <el-table-column label="实还本金" align="center" >
          <template slot-scope="{row}">
            <span>{{ row.realPrin }}</span>
          </template>
        </el-table-column>
        <el-table-column label="实还利息" align="center" >
          <template slot-scope="{row}">
            <span>{{ row.realInter }}</span>
          </template>
        </el-table-column>
        <el-table-column label="实还总金额" align="center" >
          <template slot-scope="{row}">
            <span>{{ row.ramt }}</span>
          </template>
        </el-table-column>
        <el-table-column label="还款状态" align="center" >
          <template slot-scope="{row}">
            <span v-if="row.paidFlag=='00'">未还款</span>
            <span v-if="row.paidFlag=='10'">部分还款</span>
            <span v-if="row.paidFlag=='20'">正常还款</span>
            <span v-if="row.paidFlag=='30'">提前还款</span>
            <span v-if="row.paidFlag=='40'">逾期还款</span>
            <span v-if="row.paidFlag=='50'">核销收回</span>
          </template>
        </el-table-column>
        <el-table-column label="还款渠道" align="center" >
          <template slot-scope="{row}">
            <span>{{ row.channel }}</span>
          </template>
        </el-table-column>
        <el-table-column label="还款日期" align="center" >
            <template slot-scope="{row}">
              <span  v-if="row.paidFlag=='20'">{{ row.paidDate }}</span>
            </template>
          </el-table-column>

        </el-table>
    </el-dialog>
    <el-dialog :visible.sync="dialogRecordAble" class="abow_dialog" title="催收记录"  width="750px" >
        <collectForm :order_id="form.order_id" @cancel="addStatus=false;" v-if="addStatus"></collectForm>
        <div class="radio">
          催收记录：
          <el-button type="primary" round size="mini" @click="addStatus=true" v-if="addStatus==false">新增记录</el-button>
        </div>
        <collectRecord :order_id="form.order_id" v-if="dialogRecordAble&&addStatus==false" ></collectRecord>
    </el-dialog>   
    <el-dialog :visible.sync="prosecutionAble" class="abow_dialog" title="起诉地址标记"  width="250px" >
      <prosecution_place ref="prosecution_place_able"/>
      <el-button type="primary"  @click="prosecutionSubmit" >确定</el-button>
    </el-dialog> 
    <el-dialog :visible.sync="dialogPlanInvestorAble" class="abow_dialog" title=""  width="1050px" >
      <div style="width: 100%;border: 1px solid #eee;">
        <div style="width: 100%;border-bottom: 1px solid #eee;height: 40px;line-height: 40px;padding-left: 30px;color: orange;">基础信息</div>
        <div style="width: 100%;border-bottom: 1px solid #eee;height: auto;padding-left: 30px;">
          <el-row style="margin-top:20px;font-size:14px;color:#666;margin-bottom: 10px;">
            <el-col :span="8">客户姓名：{{ orderdetail.real_name }}</el-col>
            <el-col :span="8">联系电话：{{ orderdetail.mobile }}</el-col>
            <el-col :span="8">身 份 证：{{ orderdetail.idcard }}</el-col>
          </el-row>
          <el-row style="margin-top:20px;font-size:14px;color:#666;margin-bottom: 10px;">
            <el-col :span="8">借据编号：{{ orderdetail.loan_no }}</el-col>
            <el-col :span="8">贷款本金：{{ orderdetail.total_money }}</el-col>
            <el-col :span="8">申请期数：{{ orderdetail.total_period }}</el-col>
          </el-row>
          <el-row style="margin-top:20px;font-size:14px;color:#666;margin-bottom: 10px;">
            <el-col :span="8">已还金额：{{ orderdetail.paid_money }}</el-col>
            <el-col :span="8">已还本金：{{ orderdetail.paid_benjin }}</el-col>
            <el-col :span="8">已还利息：{{ orderdetail.paid_rate }}</el-col>
          </el-row>
          <el-row style="margin-top:20px;font-size:14px;color:#666;margin-bottom: 10px;">
            <el-col :span="8">放款日期：{{ orderdetail.first_paid_time }}</el-col>
            <el-col :span="8">剩余未还本金：{{ orderdetail.no_paid_benjin }}</el-col>
          </el-row>
        </div>
       
      </div>
      <div style="width: 100%;border: 1px solid #eee;margin-top: 10px;">
        <div style="width: 100%;border-bottom: 1px solid #eee;height: 40px;line-height: 40px;padding-left: 30px;color: orange;">还款计划</div>
        <el-table  :key="tableKey" v-loading="listLoading" :data="plan_list" size="mini" :row-class-name="tableRowClassName" border fit highlight-current-row style="width: 98%;margin: 1%;">
          <el-table-column label="客户姓名" align="center" width="100" >
            <template slot-scope="{row}">
              <span>{{ orderdetail.real_name }}</span>
            </template>
          </el-table-column>
      
          <el-table-column label="期数" align="center" width="50" >
            <template slot-scope="{row}">
              <span>{{ row.num }}</span>
            </template>
          </el-table-column>
          <el-table-column label="还款日" align="center" width="100" >
            <template slot-scope="{row}">
              <span>{{ row.date }}</span>
            </template>
          </el-table-column>
          <el-table-column label="应还金额" align="center" width="90" >
            <template slot-scope="{row}">
              <span>{{ row.monthlyPayment }}</span>
            </template>
          </el-table-column>
          <el-table-column label="应还本金" align="center" width="90" >
            <template slot-scope="{row}">
              <span>{{ row.monthlyBenjin }}</span>
            </template>
          </el-table-column>
          <el-table-column label="应还利息" align="center" width="90" >
            <template slot-scope="{row}">
              <span>{{ row.monthlyRate }}</span>
            </template>
          </el-table-column>
          <el-table-column label="已还本金" align="center" width="90" >
            <template slot-scope="{row}">
              <span>{{ row.paidbenjin }}</span>
            </template>
          </el-table-column>
          <el-table-column label="已还利息" align="center" width="90" >
            <template slot-scope="{row}">
              <span>{{ row.paidrate }}</span>
            </template>
          </el-table-column>
          <el-table-column label="已还还总额" align="center" width="90" >
            <template slot-scope="{row}">
              <span>{{ row.paidmoney }}</span>
            </template>
          </el-table-column>
  
          <el-table-column label="还款状态" class-name="status-col" >
            <template slot-scope="{row}">
              {{ row.status_name}}
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-dialog>
    
  </div>
</template>

<script>
  import {
    collectRecordAdd,
    getOrderPaymentOverList,
    sendTipsByAdmin,
    getCollectWay,
    overdueExcelout,
    tagProsecution
  } from '@/api/collection'
  import excelout from '@/components/excelout/index.vue'
  import {
    paymentList,getRegion,backendgetmerchantregion,haierPaymentList,prosecutionSubmit,investorpaymentList
  } from '@/api/finance'
  import {
    getAllList
  } from '@/api/user'
  import { merchantListOnlyMerchant } from '@/api/merchant'
  import  collectRecord  from '@/components/collect/index.vue'
  import  collectForm  from '@/components/collect/form.vue'
  import { fetchList } from '@/api/sale'
  import {
    formatDate
  } from '@/utils/formatDate.js'
  import waves from '@/directive/waves' // waves directive
  import Pagination from '@/components/Pagination' // secondary package based on el-pagination
  import prosecution_place from '@/components/prosecutionPlace/place.vue'
  export default {
    name: 'NormalTable',
    components: {
      Pagination,prosecution_place,
      collectRecord,
      collectForm,
      excelout
    },
    directives: {
      waves
    },
    data() {
      return {
        orderdetail:{},
        investor:[],
        dialogPlanInvestorAble:false,
        prosecutionAble:false,
        prosecution_data:{
          order_id:'',
          place_id:'',
          investor_id:1
        },
        dialogHaierPlanAble:false,
        haier_plan_list:[],
         action: process.env.VUE_APP_BASE_API + 'upload/file',
         myHeaders: {
           token: this.$store.getters.token
         },
        tableKey: 0,
        addStatus:false,
        tableRecord: 1,
        list: null,
        plan_list:[],
        orderinfo:[],
        way_list:[],
        status_filters:[{ text: '已还', value: '1' }, { text: '未还', value: '1,2' }],
        order_ids:[],
        listRecordLoading: true,
        recordTotal: 0,
        total: 0,
        dialogPlanAble:false,
        dialogRecordAble:false,
        listLoading: true,
        listQuery: {
          prosecution:'',
          city: '',
          enforce:'',
          page: 1,
          limit: 10,
          real_name: '',
          mobile: '',
          idcard: '',
          b_model:'',
          is_paid: '',
          status:'',
          date:'',
          merchant:'',
          sale_id:'',
          collector_id:'',
          record_date_start:'',
          record_date_end:'',
          result:'',
          days:'',
          pass_time:'',
          buyback:1
        },
        notice_query:{
          page: 1,
          limit: 10,
          is_notice:1,
        },
        notice:0,
        listRecordQuery: {
          page: 1,
          limit: 20,
          order_id: ''
        },
        qs_form: {
          status: false,
          order_id: ''
        },
        system_admin_list:[],
        temp: {
          collection_id: null
        },
        order_id:0,
        dialogFormVisible:false,
        dialogRecordVisible: false,
        dialogStatus: '',
        downloadLoading: false,
        reverse:false,
        form: {
          way: [],
          result:'',
          desc: '',
          order_id:''
        },
        listMerchantQuery: {
          page: 1,
          limit: 500
        },
        listCollectorQuery: {
          role_id: 8,
          page: 1,
          limit: 10
        },
        collect_list: [],
        merchant_list: [],
        sale_list: [],
        collector:[],
        city: [],
        query:{
          order_id:''
        }
      }
    },
    created() {
      this.cacheQueryFormat();
      this.getList(this.listQuery);
      this.getWay();
      this.getMerchantList();
      this.getSaleList();
      this.getCollectorList();
      this.getRegionList();
      //添加钩子，页面刷新
      window.addEventListener('beforeunload', e => this.beforeunloadFn(e))
    },
    destroyed() {
      //添加钩子，页面刷新
      window.removeEventListener('beforeunload', e => this.beforeunloadFn(e))
    },
    methods: {
      planinvestor(row){
        this.dialogPlanInvestorAble = true;
        this.orderdetail = row;
        let param = {order_id:row.order_id};
        investorpaymentList(param).then(response => {
          this.plan_list = response.data.list
          this.orderdetail.loan_no = this.plan_list[0].loan_no
          this.orderdetail.first_paid_time = response.data.first_paid_time
          this.orderdetail.paid_money = response.data.paid_money
          this.orderdetail.paid_benjin = response.data.paid_benjin
          this.orderdetail.paid_rate = response.data.paid_rate
          this.orderdetail.no_paid_benjin = response.data.no_paid_benjin
          this.listLoading = false
        })
      },
      prosecutionPlace(order_id){
        this.prosecution_data.order_id = order_id;
        this.prosecutionAble = true;
      },
      prosecutionSubmit(){
        const place_id = this.$refs.prosecution_place_able.$data.listQuery.place_id
        this.prosecution_data.place_id = place_id
      
        prosecutionSubmit(this.prosecution_data).then(response => {
          this.$notify({
            title: '提示',
            message: '操作成功',
            type: 'success',
            duration:1000,
            onClose:this.getList(this.listQuery)
          });
          this.prosecutionAble = false;
        })
      },
      showHaierMoney(order_id){
        this.dialogHaierPlanAble = true;
        this.getHaierList(order_id)
      },
      getHaierList(order_id) {
        let pam = {order_id:order_id};
        haierPaymentList(pam).then(response => {
          if(response.data.code==0){
            //this.haier_info = response.data.result
            this.haier_plan_list = response.data.result.billQueryResultItems
          }
          this.listLoading = false
        })
      },
      getWay(){
          getCollectWay().then(response => {
            this.way_list = response.data
          })
      },
     getRegionList() {
      backendgetmerchantregion(this.listQuery).then(response => {
        if (this.listQuery.city) {
          this.quyu = response.data
        } else {
          this.city = response.data
        }
      })
    },
      tableRowClassName1({row, rowIndex}) {
        if (row.color) {
          return 'warning-row';
        } else  {
          //return 'default-row';
        }
      },
      prosecution(order_id,lab){
        let pam = {order_id:order_id,lab:lab}
         this.$alert('确定操作，不可撤回', '提示', {
          confirmButtonText: '确定',
          callback: action => {
            tagProsecution(pam).then(response => {
                if(response.code==200){
                  this.$notify({
                    title: '提示',
                    message: '操作成功',
                    type: 'success',
                    duration:1000,
                    onClose:this.getList(this.listQuery)
                  });
                }
                
              })
              } 
          })
      },
      FileAcase(order_id,lab){
        let pam = {order_id:order_id,lab:lab}
        this.$alert('确定将该客户标记为已立案吗?', '提示', {
          confirmButtonText: '确定',
          callback: action => {
             tagFileAcase(pam).then(response => {
                if(response.code==200){
                  this.$notify({
                    title: '提示',
                    message: '操作成功',
                    type: 'success',
                    duration:1000,
                    onClose:this.getList(this.listQuery)
                  });
              } 
          })
          }
        });
        return;
      },
      getNotice(){
           this.getList(this.notice_query);
      },
      beforeunloadFn(e) {
        //刷新页面事件
        sessionStorage.removeItem('buyback');
      },
      getList(query) {
        sessionStorage.setItem('buyback',JSON.stringify(this.listQuery))
        this.listLoading = true
        getOrderPaymentOverList(query).then(response => {
          this.list = response.data.data
          this.total = response.data.total
          this.notice = response.data.notice
          //this.sale_list = response.data.sale
          setTimeout(() => {
            this.listLoading = false
          }, 1.0 * 200)
        })
      },
      
      cacheQueryFormat(){
        let cacheQuery = sessionStorage.getItem('buyback');
        if(cacheQuery){
          this.listQuery = JSON.parse(cacheQuery);
        }
      },
      excelout() {
        this.listLoading = true
        this.listQuery.limit = this.total;
        overdueExcelout(this.listQuery).then(response => {
          this.listLoading = false
          const filepath = response.data.path
          window.location.href = filepath
        })
      },
      getSaleList() {
        fetchList().then(response => {
          this.sale_list = response.data.data
        })
      },
      getMerchantList() {
        merchantListOnlyMerchant(this.listMerchantQuery).then(response => {
          this.merchant_list = response.data.merchant.data
          this.investor = response.data.investor
        })
      },
      getCollectorList() {
        getAllList(this.listCollectorQuery).then(response => {
          this.collector = response.data
        })
      },
      tableRowClassNameHaier({row, rowIndex}) {
      let str = '';
      switch(row.paidFlag){
        case '20':case '30':case '40':case '50':
          str = 'success-row';
          break
        case '00':
          if(row.overDueFlag==1){
            str = 'warning-row';
          }else{
            str = '';
          }
          
          break
      }

      return str;
    },
      tableRowClassName({row, rowIndex}) {
        if (row.s == 1) {
          return 'success-row';
        } else if (row.s == 2) {
          return 'warning-row';
        }
        return '';
      },
      onSubmit(){
        if(this.form.way==''||this.form.result==''){
          this.$notify({
            title: '提示',
            message: '请完善信息',
            type: 'warning',
            duration:2000
          });
          return;
        }
      
        collectRecordAdd(this.form).then(response => {
          if(response.code==200){
            this.$notify({
              title: '提示',
              message: '保存成功',
              type: 'success',
              duration:2000
            });
            this.getCollectRecord(this.form.order_id);
            this.form.way = [];
            this.form.result = '';
            this.form.desc = '';
            this.addStatus = false;
          }
          this.listLoading = false
        })
      },
      tipsByAdmin(order_id,lab){
        let pam = {};
        if(lab==1){
          pam.order_ids = [order_id];
        }else{
          if(this.order_ids.length==0){
            this.$notify({
              title: '提示',
              message: '请勾选订单',
              type: 'error',
              duration: 2000
            })
          }
          pam.order_ids = this.order_ids;
        }
        //console.log(1234);return;
        sendTipsByAdmin(pam).then(response => {
            this.$notify({
              title: '提示',
              message: '已发送',
              type: 'success',
              duration: 2000
            })
        })
      },
      distribution(){
          this.dialogFormVisible = true;
      },
      handleFilter() {
        this.listQuery.page = 1
        const place_id = this.$refs.prosecution_place.$data.listQuery.place_id
        this.listQuery.place_id = place_id
        this.getList(this.listQuery)
      },
      plan(order_id){
        this.dialogPlanAble = true;
        let param = {order_id:order_id};
        paymentList(param).then(response => {
          this.plan_list = response.data.list
          this.orderinfo = response.data.order
          this.listLoading = false
        })
      },
    
      detail(order_id) {
        this.$router.push('/order/detail/' + order_id)
      },
      record(order_id){
        this.dialogRecordAble = true;
        this.form.order_id = order_id;
      },
    }
}
</script>

<style>
.collectcss{margin-top:7px;color:#999;font-size:14px}
.el-table .warning-row {
      background: orangered;
    }

  .el-table .success-row {
    background: #98dd72;
  }
  .item {
  margin-top: 10px;
}
</style>
